package com.app.toolboxlibrary;

import android.graphics.drawable.Drawable;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 *
 */
public class AboutJavaClass {

    public static void main(String args[]){
//        System.out.print(DateUtil.getYear(new Date()));
//        System.out.print(DateUtil.getMonth(new Date()));
//        System.out.print(DateUtil.getDay(new Date()));
        String suijiString = "!@#$%^&*()Q5" ;
        suijiString = suijiString + "getDict119110" ;
        String jiamihou =  BitmapUtils.md5("getDict119110".getBytes());
        jiamihou = "5D:D2:3C:9D:66:00:BD:5F:0B:5E:0F:9C:B7:21:33:05:2A:30:BB:18" ;
//        System.out.print(jiamihou.replace(":",""));
        String mima = "Cpic12345!";
        //Q3BpYzEyMzQ1IQ==
        System.out.print(Base64Utils.encode(mima.getBytes()));
        //d84163c0a0b7910bce0ceff769754ac5
        //d84163c0a0b7910bce0ceff769754ac5
    }

    // 反射私有的构造方法
    public static void reflectPrivateConstructor( Class<?> classBook ) {
        try {
            //此处传入的类型需要和newInstance（）传入的数据保持统一
            Constructor<?> declaredConstructorBook = classBook.getDeclaredConstructor(Drawable.class, String.class, String.class, boolean.class, long.class);
            declaredConstructorBook.setAccessible(true);
            //无参数的构造方法
            //Object objectBook = declaredConstructorBook.newInstance();
            Object objectBook = declaredConstructorBook.newInstance( null, "appName", "packageName", false, 0);
            AppInfo book = (AppInfo) objectBook;
            System.out.println("设置输出结果:"+book.toString() );
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // 反射私有属性
    public static void reflectPrivateField(Class<?> classBook) {
        try {
            Object objectBook = classBook.newInstance();
            //私有属性的 变量名称
            Field fieldTag = classBook.getDeclaredField("serialVersionUID");
            fieldTag.setAccessible(true);
            long tag = (long) fieldTag.get(objectBook);
            System.out.println("siyou shuxing:"+tag );
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // 反射私有方法
    public static void reflectPrivateMethod(Class<?> classBook) {
        try {
            //formatdatewithMonthandDay 方法名，
            //String.class，多个参数以此传入对象类型
            Method methodBook = classBook.getDeclaredMethod("declaredMethod",int.class);
            methodBook.setAccessible(true);
            Object objectBook = classBook.newInstance();
            //同理调用的时候需要传入对相应的参数
            String string = (String) methodBook.invoke(objectBook,0);
            System.out.println("reflectPrivateMethod 方法:"+string );
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }


}
